import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.exceptions.CannotReadException;
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException;
import org.jaudiotagger.audio.exceptions.ReadOnlyFileException;
import org.jaudiotagger.audio.mp3.MP3File;
import org.jaudiotagger.tag.FieldKey;
import org.jaudiotagger.tag.TagException;
import org.jaudiotagger.tag.id3.AbstractID3v2Tag;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;

public class test {
    public void getMP3Info(String url) throws CannotReadException, TagException, InvalidAudioFrameException, ReadOnlyFileException, IOException {

        MP3File mp3File = (MP3File) AudioFileIO.read(new File(url));
        AbstractID3v2Tag v2tag = mp3File.getID3v2Tag();

        String artist = v2tag.getFirst(FieldKey.ARTIST);// 歌手名
        String album = v2tag.getFirst(FieldKey.ALBUM);// 專輯名
        String songName = v2tag.getFirst(FieldKey.TITLE);// 歌名
        System.out.println("album: " + album); // 專輯名
        System.out.println("singer: " + artist); // 歌手名
        System.out.println("songName: " + songName); // 歌名
    }
    @Test
    public void test1() throws CannotReadException, TagException, InvalidAudioFrameException, ReadOnlyFileException, IOException {
        System.out.println(123);
        getMP3Info("E:\\CloudMusic\\春奈るな - LOVE TEARS.mp3");
    }
}
